Repository navigation
Conversation
A span read walked the BDA table for every access. Single-wave address-based programs pay that walk on their critical path: in Ghost of Yotei's opening cinematic, 0x807b90a100 spends 94 % of its time in a triangle loop of six runtime-format buffer loads, and the walk was about a third of each load. Each invocation now keeps the last four ranges its span reads found. A read inside one of them translates directly; a miss walks the table with the range-returning lookup and replaces the oldest entry with the range it finds. A kept range ends at the next range's start, so a hit resolves exactly as the walk would. The entries are separate variables indexed by constants, which keeps their local-memory footprint small. APS5_NO_BDA_RANGE_CACHE=1 walks the table for every read, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request is labeled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Draft: not ready for review yet. The change and the results below are real; the open items are listed at the end of this section.
Address-based (BDA) span reads walk the BDA table (
probe_bda_pointer) on every access. A program that runs as one wave pays every walk on its critical path, because nothing else is resident to hide the latency. In Ghost of Yotei's opening cinematic, the single-wave program 0x807b90a100 spends 94 % of its time in a triangle loop of six runtime-format buffer loads. Shader-clock instrumentation of that loop shows the table walk is about a third of each load (~2,950 of ~8,400 cycles); the data load itself is ~220 cycles.Each invocation now keeps the last four ranges its span reads found, as
(begin, bound, device base)entries.bda_anchor_range, with the same checks as the probe) and replaces the oldest entry with the range it finds.The entries are separate variables indexed only by constants. A first version indexed 16 slots by pc; its dynamically indexed array added 512 bytes of local memory per thread on NVIDIA, and that showed up as 270 MB more VRAM in the frame replay. The four-entry version adds 176 bytes and about 40 MB.
APS5_NO_BDA_RANGE_CACHE=1walks the table for every read, as before.Still to do before this is ready:
main-vs-PR summary from the same machine and scene. Ghost of Yotei only runs on the Celegans12yotei/bestfork, so the in-game numbers below come from that fork, not frommain. I still need a title or homebrew that runs onmainand exercises address-based span reads.BdaSpanReadResultTypeand the stop handling) for a different purpose, masking writes after faults. Whichever lands second needs a rebase.Overlap: the pr-overlap bot could not compare 54 open PRs that conflict with
main, so I reviewed them by hand.docs/dev/ENVIRONMENT.md(rows in the variable table).SpirvEmitterState.hpp, where this PR adds one field (bdaRangeCache). Their additions there are unrelated: fault masking (test(shader): skip faulting wave test on narrow subgroups boykopovar/AnyPS5#6751, fix(shader): mask writes after barrier-safe BDA faults boykopovar/AnyPS5#7392), device image tables and samplers (feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) boykopovar/AnyPS5#7642, feat(agc): serve lane-keyed, pointer and runtime image-table columns boykopovar/AnyPS5#10193, feat(agc): resolve table samplers through device image keys boykopovar/AnyPS5#13928, feat(agc): resolve runtime sampler addresses through device image keys boykopovar/AnyPS5#13929), the mesh fallback (feat(agc): run mesh-path draws through a compute pass on devices without mesh shaders boykopovar/AnyPS5#9356, feat(agc): emulate mesh-fallback barycentrics through tessellation boykopovar/AnyPS5#9387), spanned-wave subgroups (perf(shader): let spanned waves run at any host subgroup size where it can be narrower than 32 boykopovar/AnyPS5#8004), stencil export (feat(agc): export stencil operation values through an attachment boykopovar/AnyPS5#10351), MoltenVK image atomics (fix(shader): order an image store before a later image atomic on MoltenVK boykopovar/AnyPS5#10652), f16/f64 modes (perf(shader): keep native f16 conversion NaN results when a startup probe matches RDNA boykopovar/AnyPS5#11351, fix(shader): declare f16 and f64 DenormPreserve together when their modes are shared boykopovar/AnyPS5#11483), and the ARM64 AOT consolidation (feat(aot): consolidate native ARM64 compiler, runtime and consumers boykopovar/AnyPS5#5021).SpirvBdaRead.cpp(see above).Tested
Windows 11 Pro 10.0.26200, RTX 3080 Ti, NVIDIA 616.92.
New
agc_driver_bda_range_cachetest. Eight loads over five guest blocks: A, A again (a hit), then B, C and D (misses), E (evicts A), A (evicts B) and B. It runs on wave32, wave64 and split wave64, with and withoutglc, and also passes withAPS5_NO_BDA_RANGE_CACHE=1.Focused tests on this branch rebased onto
main6fe120d, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(ctest -R "bda_range_cache|bda_span_reads|bda_anchor_reads|bda_device|global_loads|gpu_buffer_format|buffer_format|descriptor_web_faults|buffer_load_store" -V):main: 15/15 passed.VUID-line or a missing-layer message.spirv-val --target-env vulkan1.3passes for the five largest captured Ghost of Yotei programs (on the earlier base).Frame replay (
agc_frame_replay, exact mode) of a captured cinematic frame, alternating runs with the cache off and on. These runs used the first, pc-indexed version; the four-entry version gives 0x807b90a100 122.5 ms in the same replay. Output buffers are byte-identical in every run.Shader-clock cycles of 0x807b90a100 and 0x807b925400 drop 34 % with the first version. With four entries, 1 of 42,846 reads walks the table.
In game, Ghost of Yotei (PPSA26344), on the
yotei/bestfork's runtime (see above). The change build also carried a spanned-ballot change that measured −1 to −6 % on these programs. Warm shader cache,tools/trace_digest.pyofaps5-summary.jsonl:Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code